package com.flute.haflute.jobbox.communication.messages;

import java.util.HashMap;
import java.util.Map;

import com.flute.haflute.jobbox.base.mapreduce.MRJobConf;

/**
 * 在主节点和子节点之间传输的map请求的封装类
 */
public class MapperReqMessage implements RequestMessage {
	private static final long serialVersionUID = 1L;
	public static final String type = "MapperReqMessage";

	private MRJobConf jobConf = null;
	// 经过划分的<key,value>输入对
	private Map<String, String> keyValues = new HashMap<String, String>();

	public MapperReqMessage(MRJobConf jobConf) {
		this.jobConf = jobConf;
	}

	public MRJobConf getJobConf() {
		return jobConf;
	}

	public void setJobConf(MRJobConf jobConf) {
		this.jobConf = jobConf;
	}

	public String getMapTaskNo() {
		return this.jobConf.getJobId();
	}

	public Map<String, String> getKeyValues() {
		return keyValues;
	}

	@Override
	public Object getContent() {
		return getJobConf();
	}

	@Override
	public void setContent(Object obj) {
		if (obj instanceof MRJobConf)
			setJobConf((MRJobConf) obj);
	}

	@Override
	public String getMessagerId() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSourceId() {
		return jobConf.getJobId();
	}

	@Override
	public String getType() {
		return type;
	}

}
